<template>
    <div>
        <h3>公告列表</h3>
        <div>
            <input type="button" value="公告添加" class="btn btn-primary" @click="add"/>
            <input type="button" value="导出" class="btn btn-warning" @click="emportexcel"/>
        </div>
        标题:<input type="text" v-model="queryInfo.title"/>
        公告类型:
        <select v-model="queryInfo.noticeType">
            <option value="">请选择</option>
            <option :value="1">服务协议</option>
            <option :value="2">招股说明书</option>
            <option :value="3">收购报告书</option>
        </select>
        <input type="button" value="查询" class="btn btn-info" @click="getList"/>
        <table class="table table-bordered">
            <tbody>
                
                <tr style="background: steelblue;color: aliceblue;">
                    <td>ID</td>
                    <td>标题</td>
                    <td>类型</td>
                    <td>图片</td>
                    <td>状态</td>
                    <td>发布时间</td>
                    <td>操作</td>
                </tr>
                <tr v-for="item in data.list" :key="item.id">
                    <td>{{item.id}}</td>
                    <td>{{item.title}}</td>
                    <td>
                        <span v-if="item.noticeType==1">服务协议</span>
                        <span v-if="item.noticeType==2">招股说明书</span>
                        <span v-if="item.noticeType==3">收购报告书</span>
                    </td>
                    <td><img :src="item.photo" alt="" width="100" height="100"></td>
                    <td>{{item.state==1?"显示":"隐藏"}}</td>
                    <td>{{ moment(item.createTime).format('YYYY-MM-DD') }}</td>
                    <td>操作</td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,reactive,onMounted} from 'vue'
import axios from 'axios';
import moment from 'moment';
import {useRouter,useRoute} from 'vue-router'
const router=useRouter();
const route=useRoute();

const add=()=>{
    router.push('/noticeAdd');
}

onMounted(()=>{
    getList();
})
const emportexcel=()=>{
    location.href=`https://localhost:7110/api/Notice/ExportExcel`
}
//显示
let queryInfo=reactive({
    title:'',
    noticeType:''
});
let data:any=reactive({
    list:[]
})
const getList=()=>{
    axios({
        url:'/api/Notice/GetNoticeList',
        method:'get',
        params:queryInfo
    })
    .then((res)=>{
        console.log(res);
        data.list=res.data;
    })
    .catch((err)=>{
        console.log(err);
    })
}
</script>

<style scoped>

</style>